package com.driving.single.common.user.service.impl;

import com.driving.single.common.domain.TbUser;
import com.driving.single.common.mapper.TbUserMapper;
import com.driving.single.common.user.service.CommonUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class CommonUserServiceImpl implements CommonUserService {
    @Autowired
    private TbUserMapper tbUserMapper;

    /**
     * 用户登录接口
     *
     * @param account  帐号
     * @param password 密码
     */
    @Override
    public TbUser userLogin(String account, String password) {
        Example example = new Example(TbUser.class);
        example.createCriteria().andEqualTo("password", password);
        List<TbUser> tbUsers = this.tbUserMapper.selectByExample(example);
        if (tbUsers.size() == 1) {
            return tbUsers.get(0);
        }
        return null;
    }
}
